package com.oocl.o2o.admin.controller;

import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.oocl.o2o.admin.entity.ComplaintInfo;
import com.oocl.o2o.admin.service.ComplaintInfoService;
import com.oocl.o2o.admin.vo.ComplainVO;
import com.oocl.o2o.admin.vo.ComplaintsVo;

@Controller
@RequestMapping("/sec/complaint")
public class ComplaintInfoController {

	@Resource(name = "complaintInfoServiceImpl")
	private ComplaintInfoService complaintInfoService;
	
	private static Logger logger = Logger.getLogger(ComplaintInfoController.class);

	@GetMapping
	public String listComplaint(Model model) {

		List<ComplainVO> complainVoList = complaintInfoService
				.findAllComplaintByMerchant();
		model.addAttribute("complainVoList", complainVoList);
		logger.info("展示投诉列表");
		return "sec/showAllComplains";

	}

	@ResponseBody
	@GetMapping("/{merchantId}")
	public List<ComplaintsVo> findByMerchantId(@PathVariable("merchantId") String id, Model model) {
		List<ComplaintsVo> complaintlist = complaintInfoService.findByMerchantId(id);
		return complaintlist;
	}

}
